package com.dongdongshop.controller;

import com.dongdongshop.data.Page;
import com.dongdongshop.data.Result;
import com.dongdongshop.pojo.TbBrand;
import com.dongdongshop.pojo.TbContentCategory;
import com.dongdongshop.service.ContentCategoryService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("contentCategory")
public class ContentCategoryController {
    @DubboReference
    private ContentCategoryService contentCategoryService;

    @RequestMapping("toShow")
    public String toShow(){
        return "admin/content_category";
    }

    @RequestMapping("findList")
    @ResponseBody
    public Result findList(@RequestParam(defaultValue = "1")Integer pageNum,
                           @RequestParam(defaultValue = "3")Integer pageSize,
                           TbContentCategory tbContentCategory){
        Page<TbContentCategory> page = contentCategoryService.findList(pageNum,pageSize,tbContentCategory);
        return Result.ok().setData(page);
    }

    @RequestMapping("addInfo")
    @ResponseBody
    public Result addInfo(TbContentCategory tbContentCategory){
        contentCategoryService.addInfo(tbContentCategory);
        return Result.ok();
    }

    @RequestMapping("selectById")
    @ResponseBody
    public Result selectById(TbContentCategory tbContentCategory){
        TbContentCategory tcc = contentCategoryService.selectById(tbContentCategory);
        return Result.ok().setData(tcc);
    }

    @RequestMapping("UpdateInfo")
    @ResponseBody
    public Result UpdateInfo(TbContentCategory tbContentCategory){
        contentCategoryService.UpdateInfo(tbContentCategory);
        return Result.ok();
    }

    @RequestMapping("deleteInfo")
    @ResponseBody
    public Result deleteInfo(Long[] id){
        contentCategoryService.deleteInfo(id);
        return Result.ok();
    }
}
